<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="../css/mui.min.css">
		<link rel="stylesheet" type="text/css" href="../css/mui.picker.min.css" />
		<link rel="stylesheet" href="../css/iconfont.css">
		<style>
			.mui-content-padded{margin:5px 0 0 0;}
			.mui-row-list span{float: left; line-height:33px; width:20%;}
			.mui-row-list select{float: left; line-height:14px; font-size:14px; margin-top:2px; margin-left: 5px;}
			.mui-btn-block{margin-bottom:0; padding:6px;}
			.mui-col-sm-12{ border-top: 1px solid #D1D1D1; width:100%; padding-top:5px; font-size:14px;}
			.mui-switch:before {content: '否'; color: #999;}
			.mui-switch.mui-active:before {content: '是'; color: #fff;}
			.mui-switch.two:before {content: '正常'; color: #999;}
			.mui-switch.two.mui-active.two:before {content: '撤销'; color: #fff;}
			.mui-table-view-cell.mui-active{ display:block;}
			input{border-width:0; text-align: right; font-size:14px;}
			.bottom_soild{border-bottom: 1px solid #DDDDDD}
			.mui-ul-check{ width: 100%; margin: 0; padding: 0;}
			.mui-ul-check li{float: left; list-style-type:none; text-align: center; padding:3px; margin:2px; border:1px solid #D1D1D1;}
			.mui-ul-check li.on{ background-color:#007AFF; color:#FFFFFF; float: left; list-style-type:none; text-align: center; padding:3px; margin:2px;}
			.mui-popover .mui-scroll-wrapper{ margin: 0;}
			/* 弹窗样式 */
			.mui-scroll-wrapper{height:4rem;}
			.mui-popover .mui-scroll-wrapper{margin:0;}
			.submit{
				margin:0 auto 10px auto; 
				width:200px; 
				height:35px; 
				line-height: 35px; 
				background-color:#007AFF; 
				text-align: center; 
				color: #FFFFFF; 
				border-radius: 10px;
			}
		</style>
	</head>
	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title" id="high_id">高血压专档</h1>
			<a id="menu" class="mui-action-menu mui-icon mui-icon-bars mui-pull-right" href="#topPopover"></a>
		</header>
		<!--右上角弹出菜单-->
		<div id="topPopover" class="mui-popover">
			<div class="mui-popover-arrow"></div>
			<div class="mui-scroll-wrapper">
				<div class="mui-scroll">
					<ul class="mui-table-view">
						<li class="mui-table-view-cell"><a href="javascript:void(0)" onclick="homeback()">返回首页</a></li>
						<!-- <li class="mui-table-view-cell"><a href="javascript:void(0)" onclick="news_delet()">删除记录</a></li> -->
						<!-- <li class="mui-table-view-cell"><a href="javascript:void(0)" onclick="follow_back()">随访查询</a></li> -->
					</ul>
				</div>
			</div>
		</div>
		<div class="mui-conten" style="margin-top:50px;">
			<ul class="mui-table-view">
				<div class="mui-row">
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<a data-options='{"type":"date"}' class="btn mui-navigate-right">
								<div style="float: left; font-size: 16px; width:5rem;">建档人</div>
								<input  id='result0' class="ui-alert"  placeholder="请选择" style="width:50%; float:right; margin-right:15px;"/>
							</a>
						</li>
					</div>
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<a data-options='{"type":"date"}' class="btn mui-navigate-right">
								<div style="float: left; font-size: 16px; width:5rem;">检出途径</div>
								<input  id='result1' class="ui-alert"  placeholder="请选择" style="width:50%; float:right; margin-right:15px;"/>
							</a>
						</li>
					</div>
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<a data-options='{"type":"date"}' class="btn mui-navigate-right">
								<div style="float: left; font-size: 16px; width:5rem;">高血压类型</div>
								<input  id='result2' class="ui-alert"  placeholder="请选择" style="width:50%; float:right; margin-right:15px;"/>
							</a>
						</li>
					</div>
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<a data-options='{"type":"date"}' class="btn mui-navigate-right">
								<div style="float: left; font-size: 16px; width:5rem;">确诊时间</div>
								<input  id='result3' class="ui-alert"  placeholder="请选择" style="width:50%; float:right; margin-right:15px;"/>
							</a>
						</li>
					</div>
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<a data-options='{"type":"date"}' class="btn mui-navigate-right">
								<div style="float: left; font-size: 16px; width:5rem;">血压知晓情况</div>
								<input  id='result4' class="ui-alert"  placeholder="请选择" style="width:50%; float:right; margin-right:15px;"/>
							</a>
						</li>
					</div>
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<div style="float: left; font-size: 16px; width:5rem;">未服用降压药血压水平</div>
							<input class="ui-alert bottom_soild" name="sbp" id="sbp"  placeholder="单位" value="" data-type="Q85" style="width:23%; margin-top:9px; margin-left: 0.625rem;"/>/
							<input class="ui-alert bottom_soild" name="dbp" id="dbp"  placeholder="单位" value="" data-type="Q85" style="width:23%;"/>mmhg
						</li>
					</div>
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<a data-options='{"type":"date"}' class="btn mui-navigate-right">
								<div style="float: left; font-size: 16px; width:5rem;">是否服用降压药</div>
								<input  id='result5' class="ui-alert"  placeholder="请选择" style="width:50%; float:right; margin-right:15px;"/>
							</a>
						</li>
					</div>
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<div style="float: left; font-size: 16px; width:70%;">每月服用药物的费用</div>
							<div style="float:right;">元</div>
							<input class="ui-alert bottom_soild" name="hypertensionCost" id="hypertensionCost"  placeholder="价格" style="width:20%; float: right; text-align: center;"/>
						</li>
					</div>
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<div style="clear:both; font-size: 16px; margin-bottom: 4px;">不服或不规律用药的原因</div>
							<ul class="mui-ul-check" id="ularry">
								<li value="1">经济原因</li>
								<li value="2">忘记</li>
								<li value="3">不良反应</li>
								<li value="4">服用不方便</li>
								<li value="5">配药不方便</li>
								<li value="6">不需药物治疗</li>
								<li value="7">不愿意服药</li>
								<li value="8">其他</li>
							</ul>
						</li>
					</div>
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<a data-options='{"type":"date"}' class="btn mui-navigate-right">
								<div style="float: left; font-size: 16px; width:5rem;">血脂知晓情况</div>
								<input  id='result6' class="ui-alert"  placeholder="请选择" style="width:50%; float:right; margin-right:15px;"/>
							</a>
						</li>
					</div>
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<div style="float: left; font-size: 16px;">体重知晓情况</div>
							<div class="mui-switch" id="mySwitch">
							  <div class="mui-switch-handle"></div>
							</div>
						</li>
					</div>
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<a data-options='{"type":"date"}' class="btn mui-navigate-right">
								<div style="float: left; font-size: 16px; width:5rem;">靶器官损坏</div>
								<input  id='result7' class="ui-alert"  placeholder="请选择" style="width:50%; float:right; margin-right:15px;"/>
							</a>
						</li>
					</div>
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<div style="clear:both; font-size: 16px; margin-bottom:4px;">患其他慢病</div>
							<ul class="mui-ul-check" id="otherChronic">
								<li value="1">冠心病</li>
								<li value="2">脑卒中</li>
								<li value="3">慢性堵塞性肺部疾病</li>
								<li value="4">癌症</li>
							</ul>
						</li>
					</div>
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<a data-options='{"type":"date"}' class="btn mui-navigate-right">
								<div style="float: left; font-size: 16px; width:5rem;">心理调整</div>
								<input  id='result8' class="ui-alert"  placeholder="请选择" style="width:50%; float:right; margin-right:15px;"/>
							</a>
						</li>
					</div>
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<a data-options='{"type":"date"}' class="btn mui-navigate-right">
								<div style="float: left; font-size: 16px; width:5rem;">遵医行为</div>
								<input  id='result9' class="ui-alert"  placeholder="请选择" style="width:50%; float:right; margin-right:15px;"/>
							</a>
						</li>
					</div>
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<div style="float: left; font-size: 16px;">状态</div>
							<div class="mui-switch two" id="mySwitch2">
							  <div class="mui-switch-handle two"></div>
							</div>
						</li>
						<li class="mui-table-view-cell" style="display: none;" id="tigshow">
							<div style="float: left; font-size: 16px;">撤销随访管理原因</div>
							<div style="float:right; width:38%; margin-bottom: 6px;">
								<a data-options='{"type":"date"}' class="btn">
									<input  id='result10' class="ui-alert"  placeholder="选择日期" style="width:100%;"/>
								</a>
							</div>
							<textarea name="cancelReason" id="cancelReason"  cols="40"   rows="4"   style="OVERFLOW:   hidden"></textarea>
						</li>
					</div>
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<div style="float: left; font-size: 16px; width:5rem;">随访频率</div>
							<input  class="ui-alert bottom_soild" id="visitFrequency" value="" style="float: left; width:5rem; text-align:center;"  placeholder="随访频率"/>
							<a data-options='{"type":"date"}' class="btn mui-navigate-right" style="float: left;">
								<input  id='result11' class="ui-alert bottom_soild"  placeholder="年份"  style="width:5rem; float: left; margin-left: 3px; text-align: center;"/>
								/次
							</a>
						</li>
					</div>
					<div class="mui-col-sm-12 mui-col-xs-12">
						<li class="mui-table-view-cell">
							<div onclick="submit()" class="submit" >提交</div>
						</li>
					</div>
				</div>
			</ul>
		</div>
		<script src="../js/mui.js"></script>
		<script src="../js/mui.picker.min.js"></script>
		<script src="../js/jquery.min-1.11.1.js"></script>
		<script type="text/javascript">
			var resultall = {"r1":["","首诊压测","普查","门诊就诊","建行档案"],
							"r2":["","原发性高血压","续发性高血压","不详","其他"],
							"r3":["","患有高血压","血压正常","测过但不清楚","从未测过"],
							"r4":["","规律服药","间断服药","不服药"],
							"r5":["","血脂异常","血脂正常","测过但不清楚","从未测过"],
							"r6":["","左室肥厚","颈动脉内膜增厚","肾功能受损"],
							"r7":["","良好","一般","差"],
							"r8":["","日","周","月","年"]}
			var id = "0";
			var ehrId = null;
			var detectionWay =  null;
			var hypertensionType =  null;
			var findDate =  null;
			var dangerEvel =  null;
			var hypertensionYn =  null;
			var sbp =  null;
			var dbp =  null;
			var hypertensionMedicine =  null;
			var hypertensionCost =  null;
			var medicineYn =  "";
			var bloodfatYn =  null;
			var weightYn =  null;
			var otherChronic =  "";
			var organDamage =  null;
			var mentalYn =  null;
			var doctorYn =  null;
			var visitDate =  "";
			var nextTime =  "";
			var doctorName =  null;
			var hospId =  null;
			var cancelDate =  "";
			var cancelReason =  null;
			var enableFlag =  null;
			var createUser =  null;
			var createDate =  null;
			var modifyUser =  null;
			var modifyDate =  null;
			var remark="";
			var education="0";
			var profession="0";
			var doctorId =  null;
			var doctorHospId =  null;
			var doctorHospName="";
			var visitFrequency =  null;
			var visitUnit =  null;
			//获取变量
			var date1 = new Date();
			var year1=date1.getFullYear(); 
			var month1=date1.getMonth()+1;
			var day1=date1.getDate();
			var h1=date1.getHours();
			var m1=date1.getMinutes();
			var s1=date1.getSeconds();
				month1 =(month1<10 ? "0"+month1:month1); 
				day1 =(day1<10 ? "0"+day1:day1); 
				h1 =(h1<10 ? "0"+h1:h1); 
				m1 =(m1<10 ? "0"+m1:m1); 
				s1 =(s1<10 ? "0"+s1:s1);
				modifyDate = (year1.toString()+'-'+month1.toString()+'-'+day1.toString()+' '+h1.toString()+':'+m1.toString()+':'+s1.toString())
				createDate = (year1.toString()+'-'+month1.toString()+'-'+day1.toString()+' '+h1.toString()+':'+m1.toString()+':'+s1.toString());
				//visitDate = (year1.toString()+'-'+month1.toString()+'-'+day1.toString()+' '+h1.toString()+':'+m1.toString()+':'+s1.toString());
			var self = localStorage.getItem("name")
			var data = JSON.parse(self)
			hospId = data.obj.hospId;
			doctorName = data.obj.userName;
			modifyUser = data.obj.id;
			createUser = data.obj.id;
			doctorId = data.obj.id;
			doctorHospId = data.obj.hospId;
			doctorHospName = data.obj.hospName;
			var listdata = "";
			var selfdata = "";
			mui.plusReady(function(){
				var self = plus.webview.currentWebview()
					listdata = self.data
					selfdata = JSON.parse(listdata)
					ehrId = selfdata.ehrId
				mui.ajax('http://192.168.2.64:8089/mobile/ehr/Hypertension/get',{
					data:{
						"ehr_id":ehrId
					},
					dataType:'json',//服务器返回json格式数据
					type:'post',//HTTP请求类型
					timeout:10000,//超时时间设置为10秒；
					success:function(data){
						var rows = data.rows;
						console.log(rows[0].nextTime)
						if (data.status == 1) {
							 id = rows[0].id;
							 ehrId = rows[0].ehrId;
							 var rowsdetectionWay=new Array('','首诊压测','普查','门诊就诊','建行档案')
							 document.getElementById("result1").value = rowsdetectionWay[rows[0].detectionWay];
							 var rowshypertensionType=new Array('','原发性高血压','续发性高血压','不详','其他')
							 document.getElementById("result2").value = rowshypertensionType[rows[0].hypertensionType];
							 //确诊时间
							 var datef = new Date(rows[0].findDate);
							 var yearf=datef.getFullYear(); 
							 var monthf=datef.getMonth()+1;
							 var dayf=datef.getDate();
								monthf =(monthf<10 ? "0"+monthf:monthf); 
								dayf =(dayf<10 ? "0"+dayf:dayf); 
							 findDate = (yearf.toString()+'-'+monthf.toString()+'-'+dayf.toString());
							 document.getElementById("result3").value = findDate;
							 var rowshypertensionYn=new Array('','患有高血压','血压正常','测过但不清楚','从未测过')
							 document.getElementById("result4").value = rowshypertensionYn[rows[0].hypertensionYn];
							 document.getElementById("sbp").value = rows[0].sbp;
							 document.getElementById("dbp").value = rows[0].dbp;
							 var rowshypertensionMedicine=new Array('','规律服药','间断服药','不服药')
							 document.getElementById("result5").value = rowshypertensionMedicine[rows[0].hypertensionMedicine];
							 document.getElementById("hypertensionCost").value = rows[0].hypertensionCost;
							 //不服药多选赋值
							 var medicineYnarr = rows[0].medicineYn;
							 if(medicineYnarr != null){
								 var medicineYnarr_n = medicineYnarr.split(",");
								 if(medicineYnarr_n.length != 0){
									$ ("#ularry").each (function (){
										$ (this).find ('li').each (function (){
											for (var i=0; i<medicineYnarr_n.length; i++) {
												if ($(this).val() == medicineYnarr_n[i]) {
							                        $(this).addClass("on")
							                    }		
											}
										})
									})	
								 }
							 }
							 //不服药多选赋值结束
							 var rowsbloodfatYn=new Array('','血脂异常','血脂正常','测过但不清楚','从未测过')
							 document.getElementById("result6").value = rowsbloodfatYn[rows[0].bloodfatYn];
							 if(rows[0].weightYn == "1"){
								$("#mySwitch").addClass("mui-active");
							 }else{
								$("#mySwitch").removeClass("mui-active");
							 }
							 var rowsorganDamage=new Array('','左室肥厚','颈动脉内膜增厚','肾功能受损')
							 document.getElementById("result7").value = rowsorganDamage[rows[0].organDamage];
							 //其它慢病多选赋值
							 var otherChronicarr = rows[0].otherChronic;
							 if(otherChronicarr != null){
								 var otherChronicarr_n = otherChronicarr.split(",");
								 if(otherChronicarr_n.length != 0){
									 $ ("#otherChronic").each (function (){
										$ (this).find ('li').each (function (){
											for (var i=0; i<otherChronicarr_n.length; i++) {
												if ($(this).val() == otherChronicarr_n[i]) {
									                       $(this).addClass("on")
									                   }		
											}
										})
									 })	
								 }
							 }
							 //不服药多选赋值结束
							 var rowsmentalYn=new Array('','良好','一般','差')
							 document.getElementById("result8").value = rowsmentalYn[rows[0].mentalYn];
							 var rowsdoctorYn=new Array('','良好','一般','差')
							 document.getElementById("result9").value = rowsdoctorYn[rows[0].doctorYn];
							 /* var datev = new Date(rows[0].visitDate);
							 var yearv=datev.getFullYear(); 
							 var monthv=datev.getMonth()+1;
							 var dayv=datev.getDate();
							 var hv=datev.getHours();
							 var mv=datev.getMinutes();
							 var sv=datev.getSeconds();
								monthv =(monthv<10 ? "0"+monthv:monthv); 
								dayv =(dayv<10 ? "0"+dayv:dayv); 
								hv =(hv<10 ? "0"+hv:hv); 
								mv =(mv<10 ? "0"+mv:mv); 
								sv =(sv<10 ? "0"+sv:sv); 
								visitDate = (yearv.toString()+'-'+monthv.toString()+'-'+dayv.toString()+' '+hv.toString()+':'+mv.toString()+':'+sv.toString()); */
							 //nextTime = rows[0].nextTime;
							 document.getElementById("result0").value = rows[0].doctorName;
							 hospId = rows[0].hospId;
							 document.getElementById("result10").value = rows[0].cancelDate;
							 document.getElementById("cancelReason").value = rows[0].cancelReason;
							 if(rows[0].enableFlag == "2"){
								$("#mySwitch2").addClass("mui-active");
								document.getElementById("tigshow").style.display="block"
							 }else{
								$("#mySwitch2").removeClass("mui-active");
								document.getElementById("tigshow").style.display="none"
							 }
							 createUser = rows[0].createUser;
							 var datec = new Date(rows[0].createDate);
							 var yearc=datec.getFullYear(); 
							 var monthc=datec.getMonth()+1;
							 var dayc=datec.getDate();
							 var hc=datec.getHours();
							 var mc=datec.getMinutes();
							 var sc=datec.getSeconds();
								monthc =(monthc<10 ? "0"+monthc:monthc); 
								dayc =(dayc<10 ? "0"+dayc:dayc); 
								hc =(hc<10 ? "0"+hc:hc); 
								mc =(mc<10 ? "0"+mc:mc); 
								sc =(sc<10 ? "0"+sc:sc); 
								createDate = (yearc.toString()+'-'+monthc.toString()+'-'+dayc.toString()+' '+hc.toString()+':'+mc.toString()+':'+sc.toString());
							 remark = rows[0].remark;
							 education = rows[0].education;
							 profession = rows[0].profession;
							 doctorId = rows[0].doctorId;
							 doctorHospId = rows[0].doctorHospId;
							 doctorHospName = rows[0].doctorHospName;
							 xkSign = rows[0].xkSign;
							 document.getElementById("visitFrequency").value = rows[0].visitFrequency;
							 var rowsvisitUnit=new Array('','日','周','月','年')
							 document.getElementById("result11").value = rowsvisitUnit[rows[0].visitUnit];
						} else {
							document.getElementById("result0").value = doctorHospName;
						}
					},
					error:function(xhr,type,errorThrown){
						
					}
				});	
			});	
			mui.init()
			(function($) {
				$.init();
				var result = $('#result')[0];
				var btns = $('.btn');
				btns.each(function(i, btn) {
					btn.addEventListener('tap', function() {
						var _self = this;
						if(_self.picker) {
							_self.picker.show(function (rs) {
								result.innerText = rs.text;
								_self.picker.dispose();
								_self.picker = null;
							});
						} else {
							if(i == 0){
								var picker = new mui.PopPicker();
								 picker.setData();
								 picker.show(function (selectItems) {
									 $('#result'+i)[0].value = selectItems[0].text;
									 
								  })
							}else if(i == 1){
								var picker = new mui.PopPicker();
								 picker.setData([{value:'1',text:'首诊压测'},{value:'2',text:'普查'},{value:'3',text:'门诊就诊'},{value:'4',text:'建行档案'}]);
								 picker.show(function (selectItems) {
									 $('#result'+i)[0].value = selectItems[0].text;
								  })
							}else if(i == 2){
								var picker = new mui.PopPicker();
								 picker.setData([{value:'1',text:'原发性高血压'},{value:'2',text:'续发性高血压'},{value:'3',text:'不详'},{value:'4',text:'其他'}]);
								 picker.show(function (selectItems) {
									 $('#result'+i)[0].value = selectItems[0].text;
								  })
							}else if(i == 3){
								var optionsJson = this.getAttribute('data-options') || '{}';
								var options = JSON.parse(optionsJson);
								var id = this.getAttribute('id');
								_self.picker = new $.DtPicker(options);
								_self.picker.show(function(rs) {
									$('#result'+i)[0].value = rs.text;
									_self.picker.dispose();
									_self.picker = null;
								});
							}else if(i == 4){
								var picker = new mui.PopPicker();
								 picker.setData([{value:'1',text:'患有高血压'},{value:'2',text:'血压正常'},{value:'3',text:'测过但不清楚'},{value:'4',text:'从未测过'}]);
								 picker.show(function (selectItems) {
									 $('#result'+i)[0].value = selectItems[0].text;
								  })
							}else if(i == 5){
								var picker = new mui.PopPicker();
								 picker.setData([{value:'1',text:'规律服药'},{value:'2',text:'间断服药'},{value:'3',text:'不服药'}]);
								 picker.show(function (selectItems) {
									 $('#result'+i)[0].value = selectItems[0].text;
								  })
							}else if(i == 6){
								var picker = new mui.PopPicker();
								 picker.setData([{value:'1',text:'血脂异常'},{value:'2',text:'血脂正常'},{value:'3',text:'测过但不清楚'},{value:'4',text:'从未测过'}]);
								 picker.show(function (selectItems) {
									 $('#result'+i)[0].value = selectItems[0].text;
								  })
							}else if(i == 7){
								var picker = new mui.PopPicker();
								 picker.setData([{value:'1',text:'左室肥厚'},{value:'2',text:'颈动脉内膜增厚'},{value:'3',text:'肾功能受损'}]);
								 picker.show(function (selectItems) {
									 $('#result'+i)[0].value = selectItems[0].text;
								  })
							}else if(i == 8){
								var picker = new mui.PopPicker();
								 picker.setData([{value:'1',text:'良好'},{value:'2',text:'一般'},{value:'3',text:'差'}]);
								 picker.show(function (selectItems) {
									 $('#result'+i)[0].value = selectItems[0].text;
								  })
							}else if(i == 9){
								var picker = new mui.PopPicker();
								 picker.setData([{value:'1',text:'良好'},{value:'2',text:'一般'},{value:'3',text:'差'}]);
								 picker.show(function (selectItems) {
									 $('#result'+i)[0].value = selectItems[0].text;
								  })
							}else if(i == 10){
								var optionsJson = this.getAttribute('data-options') || '{}';
								var options = JSON.parse(optionsJson);
								var id = this.getAttribute('id');
								_self.picker = new $.DtPicker(options);
								_self.picker.show(function(rs) {
									$('#result'+i)[0].value = rs.text;
									_self.picker.dispose();
									_self.picker = null;
								});
							}else if(i == 11){
								var picker = new mui.PopPicker();
								 picker.setData([{value:'1',text:'日'},{value:'2',text:'周'},{value:'3',text:'月'},{value:'4',text:'年'}]);
								 picker.show(function (selectItems) {
									 $('#result'+i)[0].value = selectItems[0].text;
								})
							}else{
								var optionsJson = this.getAttribute('data-options') || '{}';
								var options = JSON.parse(optionsJson);
								var id = this.getAttribute('id');
								/*
								 * 首次显示时实例化组件
								 * 示例为了简洁，将 options 放在了按钮的 dom 上
								 * 也可以直接通过代码声明 optinos 用于实例化 DtPicker
								 */
								_self.picker = new $.DtPicker(options);
								_self.picker.show(function(rs) {
									/*
									 * rs.value 拼合后的 value
									 * rs.text 拼合后的 text
									 * rs.y 年，可以通过 rs.y.vaue 和 rs.y.text 获取值和文本
									 * rs.m 月，用法同年
									 * rs.d 日，用法同年
									 * rs.h 时，用法同年
									 * rs.i 分（minutes 的第二个字母），用法同年
									 */
									$('#result'+i)[0].value = rs.text;
									/* 
									 * 返回 false 可以阻止选择框的关闭
									 * return false;
									 */
									/*
									 * 释放组件资源，释放后将将不能再操作组件
									 * 通常情况下，不需要示放组件，new DtPicker(options) 后，可以一直使用。
									 * 当前示例，因为内容较多，如不进行资原释放，在某些设备上会较慢。
									 * 所以每次用完便立即调用 dispose 进行释放，下次用时再创建新实例。
									 */
									_self.picker.dispose();
									_self.picker = null;
								});
							}
						}
						
					}, false);
				});
			})(mui);
			//开关事件
			mui('.mui-switch')['switch']()
			var swit = 0;
			var swit1 = 1;
			document.getElementById("mySwitch").addEventListener("toggle",function(event){
			  if(event.detail.isActive){
					swit = 1
			  }else{
					swit = 0
			  }
			})
			document.getElementById("mySwitch2").addEventListener("toggle",function(event){
			  if(event.detail.isActive){
					swit1 = 2
			  }else{
					swit1 = 1
			  }
			})
			//切换
			document.getElementById("mySwitch2").addEventListener("toggle",function(event){
				if(event.detail.isActive){
						document.getElementById("tigshow").style.display="block"
				}else{
						document.getElementById("tigshow").style.display="none"
				}
			})
			//复选框事件
			mui('#ularry').on('tap', 'li', function(e) {
				if(!this.getAttribute('class')){
					this.classList.add('on')
				}else{
					this.classList.remove('on');
				}
			});
			mui('#otherChronic').on('tap', 'li', function(e) {
				if(!this.getAttribute('class')){
					this.classList.add('on')
				}else{
					this.classList.remove('on');
				}
			});
			//返回首页
			function homeback(){
				  //关闭当前窗口
				  var win_add=plus.webview.currentWebview();
				  plus.webview.close(win_add);
				  //获取目标页面//打开关于页面
				  mui.openWindow({
					url: '../index.html', 
					id:'index',
					extras:{
						name:'homeback'
					}
				  });
			}
			//提交
			function submit(){
				id = id
				detectionWay1 = $('#result1')[0].value//检出途径
				for(var re=0; re<resultall.r1.length; re++){
					if(detectionWay1 == resultall.r1[re]){
						detectionWay = re;
					}
				}	
				hypertensionType1 = $('#result2')[0].value//高血压类型
				for(var re=0; re<resultall.r2.length; re++){
					if(hypertensionType1 == resultall.r2[re]){
						hypertensionType = re;
					}
				}
				findDate = $('#result3')[0].value+" 00:00:00"//确诊日期
				hypertensionYn1 = $('#result4')[0].value//血压知晓情况
				for(var re=0; re<resultall.r3.length; re++){
					if(hypertensionYn1 == resultall.r3[re]){
						hypertensionYn = re;
					}
				}
				hypertensionMedicine1 = $('#result5')[0].value//是否服用降压药
				for(var re=0; re<resultall.r4.length; re++){
					if(hypertensionMedicine1 == resultall.r4[re]){
						hypertensionMedicine = re;
					}
				}
				bloodfatYn1 = $('#result6')[0].value//血脂知晓情况
				for(var re=0; re<resultall.r5.length; re++){
					if(bloodfatYn1 == resultall.r5[re]){
						bloodfatYn = re;
					}
				}
				organDamage1 = $('#result7')[0].value//靶器官损伤
				for(var re=0; re<resultall.r6.length; re++){
					if(organDamage1 == resultall.r6[re]){
						organDamage = re;
					}
				}
				mentalYn1 = $('#result8')[0].value//心理调整
				for(var re=0; re<resultall.r7.length; re++){
					if(mentalYn1 == resultall.r7[re]){
						mentalYn = re;
					}
				}
				doctorYn1 = $('#result9')[0].value//遵医行为
				for(var re=0; re<resultall.r7.length; re++){
					if(doctorYn1 == resultall.r7[re]){
						doctorYn = re;
					}
				}
				if($('#result10')[0].value != ""){
					cancelDate = $('#result10')[0].value+" 00:00:00";//撤销日期
				}else{
					cancelDate = "";
				}
				visitUnit1 = $("#result11")[0].value;//随访频率单位
				for(var re=0; re<resultall.r8.length; re++){
					if(visitUnit1 == resultall.r8[re]){
						visitUnit = re;
					}
				}
				sbp = mui("#sbp")[0].value//未服用降压药前血压水平 高值
				dbp = mui("#dbp")[0].value//未服用降压药前血压水平 低值
				hypertensionCost = mui("#hypertensionCost")[0].value//服用降压药费用
				weightYn = swit//体重知晓情况
				enableFlag = swit1//状态
				if (swit1 == 2){
					cancelReason = mui("#cancelReason")[0].value//撤销原因
				}else {
					cancelReason = ""
					mui("#cancelReason")[0].value=""
				}
				visitFrequency = mui("#visitFrequency")[0].value//随访频率
				//复选框
				medicineYn="";
				$ ("#ularry").find ('.on').each (function (){
					medicineYn += $(this).val() + ",";
				});
				//去掉最后一个逗号(如果不需要去掉，就不用写)
				if (medicineYn.length > 0) {
					medicineYn = medicineYn.substr(0,medicineYn.length - 1);
				}
				otherChronic="";
				$ ("#otherChronic").find ('.on').each (function (){
					otherChronic += $(this).val() + ",";
				});
				//去掉最后一个逗号(如果不需要去掉，就不用写)
				if (otherChronic.length > 0) {
					otherChronic = otherChronic.substr(0,otherChronic.length - 1);
				}
				//计算下次随访时间
				/* var nextbase;
				var date2 = new Date();
				if(visitUnit == "4"){
					nextbase = 12/visitFrequency
					date2.setMonth(date2.getMonth()+nextbase);
				}else if(visitUnit == "3"){
					nextbase = 30/visitFrequency
					date2.setDate(date2.getDate()+nextbase);
				}else if(visitUnit == "2"){
					nextbase = 7/visitFrequency
					date2.setDate(date2.getDate()+nextbase);
				}else if(visitUnit == "1"){
					nextbase = 24/visitFrequency
					date2.setHours(date2.getHours()+nextbase);
				}
				var year2=date2.getFullYear(); 
				var month2=date2.getMonth()+1;
				var day2=date2.getDate();
				var h2=date2.getHours();
				var m2=date2.getMinutes();
				var s2=date2.getSeconds();
					month2 =(month2<10 ? "0"+month2:month2); 
					day2 =(day2<10 ? "0"+day2:day2); 
					h2 =(h2<10 ? "0"+h2:h2); 
					m2 =(m2<10 ? "0"+m2:m2); 
					s2 =(s2<10 ? "0"+s2:s2); 
					nextTime = (year2.toString()+'-'+month2.toString()+'-'+day2.toString()+' '+h2.toString()+':'+m2.toString()+':'+s2.toString()); */
				//判断必填项
				if (findDate == " 00:00:00") {
					alert("请输入确认时间！");
				}else if(detectionWay == ""){
					alert("请输入检出途径！");
				}else if (visitFrequency == "") {
					alert("请输入随访频率！");
				}else if (visitUnit == "") {
					alert("请输入随访频率单位！");
				} else {
					mui.ajax('http://192.168.2.64:8089/mobile/ehr/Hypertension/addOrUpdate',{
						data:{
							"id":id,//主键 自增
							"ehrId":ehrId,//人口表ehrInfo的主键id
							"detectionWay":detectionWay,
							"hypertensionType":hypertensionType,
							"findDate":findDate,
							"hypertensionYn":hypertensionYn,
							"sbp":sbp,
							"dbp":dbp,
							"hypertensionMedicine":hypertensionMedicine,
							"hypertensionCost":hypertensionCost,
							"medicineYn":medicineYn,
							"bloodfatYn":bloodfatYn,
							"weightYn":weightYn,
							"otherChronic":otherChronic,
							"organDamage":organDamage,
							"mentalYn":mentalYn,
							"doctorYn":doctorYn,
							"visitDate":visitDate,
							"nextTime":nextTime,
							"doctorName":doctorName,
							"hospId":hospId,
							"cancelDate":cancelDate,
							"cancelReason":cancelReason,
							"enableFlag":enableFlag,//状态
							"createUser":createUser,//创建用户
							"createDate":createDate,//创建时间
							"modifyUser":modifyUser,//修改用户
							"modifyDate":modifyDate,
							"remark":remark,
							"education":education,//文化程度
							"profession":profession,//职业
							"doctorId":doctorId,
							"doctorHospId":doctorHospId,
							"doctorHospName":doctorHospName,
							"visitFrequency":visitFrequency,
							"visitUnit":visitUnit
						},
						dataType:'json',//服务器返回json格式数据
						type:'post',//HTTP请求类型
						timeout:10000,//超时时间设置为10秒；
						success:function(data){
							if (data.status == 1) {
								alert("成功提交")
							} else {
								alert(data.message);
							}
						},
						error:function(xhr,type,errorThrown){
							
						}
					});
				}
			}
		</script>
	</body>
</html>